<?php
/**
 * Created by PhpStorm.
 * User: reshared
 * Date: 2017/10/2
 * Time: 上午11:04
 */

namespace Index\Repository;


use Index\Repository\Tra\InstanceTrait;

class AdRepository extends BaseRepository
{
    use InstanceTrait;

    public function getOneByKey($key)
    {
        $ads = $this->model('ad')->getByKey($key);
        return $ads[0];
    }

    public function getByKeys($key = array())
    {
        if (!is_array($key)) {
            $key = array($key);
        }

        return $this->model('ad')->getByKeys($key);
    }

    public function adFormat($list)
    {
        $result = array();
        foreach ($list as $item) {
            $result[$item['key']][] = $item;
        }
        return $result;
    }
}